<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>客服经理专栏</title>
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Public/css/gxxjkefu-normalize.css">
    <link href="/Public/css/animate.css" rel="stylesheet">
    <link rel="stylesheet" href="/Public/css/model.css">
    <link rel="stylesheet" href="/Public/css/pager.css">
    <style>
        body{
            font-size: 12px;
        }
        .user_name{
            cursor: pointer;
            color: black;
        }
        .user_name:hover{
            color: #31b0d5;
        }
        .notice_info {
            padding: 25px 0 3%;
            line-height: 35px;
            color: #979797;
            float: left;
            width: 100%;
            background: #ffffff;
        }

        .feedback_ul {
            text-align: center;
            margin: 0 auto 50px;
        }

        .feedback_ul li {
            text-align: center;
            display: inline-block;
            margin: 0 30px;
        }

        .feedback_ul li a {
            color: black;
            padding: 0 0 10px;
        }

        .feedback_ul .a_active {
            color: #57bee9;
            border-bottom: solid 2px #57bee9;
        }

        .search_table thead {
            background: #f0f8fa;
            border: none;
        }

        .table {
            color: #000000;
            margin: 0 auto;
            width: 100% !important;
            text-align: center;
        }

        .search_table input {
            background: none;
            border: none;
        }

        .table > thead > tr > th {
            border-bottom: none !important;
            text-align: center !important;
        }

        .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
            border-top: 1px solid #f0f8fa !important;
            text-align: center !important;
        }

        .remark_div {
            color: black;
            height: 340px;
            width: 90%;
            margin: 200px auto 0;
            position: relative;
        }

        .remark_div input {
            position: absolute;
            right: 0;
            bottom: 0;
            background: #ff815a;
            border-radius: 3px;
            border: none;
            color: white;
            margin-top: 20px;
            width: 200px;
            height: 40px;
        }

        .remark_div textarea {
            background: #f5f5f5;
            border: none;
            padding: 1%;
        }
        .select_div input{
            width: 20%;
            margin:0px 10px 10px 1px;

            float: right;
        }
    </style>
</head>
<body>
<div id="main_C" style="float: left;width: 100%" class="animated fadeInRight">
    <div class="title_info">
        <span>反欺诈调查</span>
    </div>
    <div class="white_bgColor notice_info">
        <!--顶部选项-->
        <ul class="feedback_ul">

            <li><a href="javascript:void(0);" class="a_active">我的优质用户</a></li>
            <li><a href="javascript:void(0);">已加微信</a></li>
            <li><a href="javascript:void(0);">借款中用户</a></li>
            <li><a href="javascript:void(0);">优质用户池</a></li>
        </ul>
        <!--优质用户-->
        <div class="select_div">
            <input id="search" style="width: 200px;height: 30px" class="form-control" />
        </div>
        <div class="search_table">

            <table class="table table-hover">
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>手机号码</th>
                    <th>注册时间</th>
                    <th>收益</th>
                    <th>负责经理</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="t_good_lst" class="animated fadeInRight">

                </tbody>
            </table>
            <div id="pageone" style="width: 1200px;text-align: center;margin: 100px auto 0">
                <ul class="pagination" id="page1"></ul>
                <div class="pageJump">
                    <span>跳转到</span>
                    <input type="text"/>
                    <span>页</span>
                    <button type="button" class="button"></button>
                </div>
            </div>
        </div>
        <!--已加微信-->
        <div style="display: none" class="search_table">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>手机号码</th>
                    <th>注册时间</th>
                    <th>收益</th>
                    <th>负责经理</th>
                    <!--<th>操作</th>-->
                </tr>
                </thead>
                <tbody id="t_wx_lst" class="animated fadeInRight">
                </tbody>
            </table>

            <div id="pagetwo" style="width: 1200px;text-align: center;margin: 100px auto 0">
                <ul class="pagination" id="page2"></ul>
                <div class="pageJump">
                    <span>跳转到</span>
                    <input type="text"/>
                    <span>页</span>
                    <button type="button" class="button"></button>
                </div>
            </div>
        </div>
       <!--借款中用户-->
        <div style="display: none" class="search_table">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>手机号码</th>
                    <th>还款状态</th>
                    <th>应还款时间</th>
                    <th>逾期状态</th>
                    <th>客服经理</th>
                </tr>
                </thead>
                <tbody id="t_borrow_lst" class="animated fadeInRight">
                </tbody>
            </table>

            <div id="pagethree" style="width: 1200px;text-align: center;margin: 100px auto 0">
                <ul class="pagination" id="page3"></ul>
                <div class="pageJump">
                    <span>跳转到</span>
                    <input type="text"/>
                    <span>页</span>
                    <button type="button" class="button"></button>
                </div>
            </div>
        </div>
        <!--用户池-->
        <div style="display: none" class="search_table">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>手机号码</th>
                    <th>注册时间</th>
                    <th>收益</th>
                    <th>负责经理</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="t_total_lst" class="animated fadeInRight">
                </tbody>
            </table>
            <div id="pagefour" style="width: 1200px;text-align: center;margin: 100px auto 0">
                <ul class="pagination" id="page4"></ul>
                <div class="pageJump">
                    <span>跳转到</span>
                    <input type="text"/>
                    <span>页</span>
                    <button type="button" class="button"></button>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</div>
<script src="/Public/js/jquery-3.2.1.js"></script>
<script src="/Public/js/bootstrap.min.js"></script>
<script src="/Public/js/pager.js"></script>
<script src="/Public/js/layer/layer.js"></script>
<script src="/Public/js/layui/layui.js"></script>

<script>
    //调用父方法
    function user_info(mobile) {
        window.parent.get_user(mobile);
    }

    //获取当前tab的
    function get_data(index,page,search) {
//        console.log('ttttt',index,page,search);
        if(index==3){
            var url = "<{$SERVER_NAME}>/MyUser/in_borrow";
        } else if(index==4){
            var url = "<{$SERVER_NAME}>/MyUser/good_user_all";
        }else {
            var url = "<{$SERVER_NAME}>/MyUser/good_user_list";
        }
        console.log('indexindex', index +"000  "+page);
        $.post(url, {page: page,type:index,search:search}, function (data) {
            console.log('909090', data);
            if (data.code == '1001') {
                var obj = data.result;
                var s = "";
                var len = obj.length;
                console.log('32232', data.total);
                if(index==1){
                    var page_div="#pageone";
                    var page_id="#page1";
                }else if(index==2){
                    var page_div="#pagetwo";
                    var page_id="#page2";
                }else if(index==3){
                    var page_div="#pagethree";
                    var page_id="#page3";
                }else if(index==4){
                    var page_div="#pagefour";
                    var page_id="#page4";
                }
                if (data.count < 10) {
                    $(page_div).hide();
                }else {
                    $(page_div).show();
                }
                sessionStorage.setItem("manager_user_total", data.total);

                /*分页*/
                Page({
                    num: data.total,					//页码数
                    startnum: page,				//指定页码
                    elem: $(page_id),		//指定的元素
                    callback: function (n) {	//回调函数
                        sessionStorage.setItem('manager_user_page', n);
                        get_data(index,n);
                    }
                });

                if(index==3){

                    for (var i = 0; i < len; i++) {
                        s += " <tr> " +
                            "<td> <a class='user_name' onclick=user_info('"+ obj[i].mobile+"')>" + obj[i].name + "</a></td> " +
                            " <td>" + obj[i].user_mobile + "</td>" +
                            " <td>" + obj[i].repay_status + "</td> " +
                            " <td>" + obj[i].repay_time + "</td> " +
                            " <td>" + obj[i].is_overdue + "</td> "+
                            " <td>" + obj[i].admin + "</td> " ;
                        s+=  "</tr>";
                    }
                }else {
                    for (var i = 0; i < len; i++){
                        s += " <tr> " +
                            "<td> <a class='user_name' onclick=user_info('"+ obj[i].mobile+"')>" + obj[i].name + "</a></td> " +
                            " <td>" + obj[i].sex + "</td>" +
                            " <td>" + obj[i].user_mobile + "</td>" +
                            " <td>" + obj[i].ctime + "</td> ";
                        if(index==1){
                            s+= " <td>" + obj[i].profit + "</td> " ;
                            s+= " <td>" + obj[i].admin_name + "</td> " ;
                            s+="<td><input class='remark_btn blue_color' type='button' value='已加微信'  onclick=turn_to('"+obj[i].vid+"','"+obj[i].type+"')  /> <input class='remark_btn blue_color' type='button' value='转回'  onclick=back_to('"+obj[i].vid+"')  /> </td> " ;
                        }else if(index==2){
                            s+= " <td>" + obj[i].profit + "</td> " ;
                            s+= " <td>" + obj[i].admin_name + "</td> " ;
//                            s+=  "<td><input class='remark_btn blue_color' type='button' value='移除微信'  onclick=turn_to('"+obj[i].vid+"','"+obj[i].type+"')  />  </td> " ;
                        }else if(index==4){
                            s+= " <td>"+obj[i].profit+"</td> " ;
                            s+= " <td>---</td> " ;
                            s+=  "<td><input class='remark_btn blue_color' type='button' value='获取用户'  onclick=get_user('"+obj[i].vid+"')  />  </td> " ;
                        }
                        s+=  "</tr>";
                    }
                }

                if(index==1){
                    document.getElementById("t_good_lst").innerHTML = s;
                }else if(index==2){
                    document.getElementById("t_wx_lst").innerHTML = s;
                } else if(index==3){
                    document.getElementById("t_borrow_lst").innerHTML = s;
                }else if(index==4){
                    document.getElementById("t_total_lst").innerHTML = s;
                }
            } else {

            }
        });
    }

    //转到或者转出微信
    function turn_to(vid,type) {
          console.log('78787',vid+"  type"+type);
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var msg='';
        if(type==1){
            msg='确定已添加微信？';
        }else {
            msg='确定放弃此用户？';
        }
        layer.alert(msg, {title: '提示框', icon: 3}, function (index) {
             $.post('<{$SERVER_NAME}>/MyUser/turn_wx_user',{vid:vid,type:type},function (data){
                 if(data.code=='1001'){
                     layer.alert(data.result, {title: '提示框', icon: 1});
                     window.location.reload();
                 }
                 else {
                     layer.alert(data.result, {title: '提示框', icon: 2});
                 }

             });
            layer.close(index);
        });
        layer.close(index);
    }

    function back_to(vid) {
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var msg='确定踢出用户！';
        layer.alert(msg, {title: '提示框', icon: 3}, function (index) {
            $.post('<{$SERVER_NAME}>/MyUser/back_to_user',{vid:vid},function (data) {
                if(data.code=='1001'){
                    layer.alert(data.result, {title: '提示框', icon: 1});
                    window.location.reload();
                }
                else {
                    layer.alert(data.result, {title: '提示框', icon: 2});
                }
            });
            layer.close(index);
        });
        layer.close(index);
    }

    //客服经理获取为自己的用户
    function get_user(vid) {

        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

        var msg='确定发展为自己用户！';
        layer.alert(msg, {title: '提示框', icon: 3}, function (index) {
            $.post('<{$SERVER_NAME}>/MyUser/get_user',{vid:vid},function (data) {
                if(data.code=='1001'){
                    layer.alert(data.result, {title: '提示框', icon: 1});
                    window.location.reload();
                }
                else {
                    layer.alert(data.result, {title: '提示框', icon: 2});
                }
            });
            layer.close(index);
        });
        layer.close(index);

    }

    //信息弹框
function detail_user(vid,mobile) {

//    url='<{$SERVER_NAME}>/MyUser/user_info.html?vid='+vid+'&mobile='+mobile;
    url='http://fk.jyyjrfw.com/Report/userdetails?mobile='+mobile;
    layer.open({
        title:'认证信息',
        type: 2,
        area: ['100%', '100%'],
        maxmin: true,
        offset:'100px',
        content: url,
        success: function(layero){
            layero.find('.layui-layer-min').remove();
        }
    });

}

    $(document).ready(function () {
        $(".feedback_ul li").click(function () {
            $(".search_table").hide().eq($(this).index()).show();
            $(".feedback_ul").find("li a").removeClass("a_active");
            $(this).children("a").addClass("a_active");
            var index = $(this).index() + 1;//获取索引
            sessionStorage.setItem("manager_tab_index", index - 1);
            sessionStorage.setItem('manager_user_page', 1);
            get_data(index,1);
        });
//  返回前的页面
        var tab_index = parseInt(sessionStorage.getItem('manager_tab_index'));
        var page = parseInt(sessionStorage.getItem('manager_user_page'));
        var survey_total = parseInt(sessionStorage.getItem('manager_user_total'));
        console.log('00000tab_index',tab_index);
        console.log('00000page',page);
        console.log('00000survey_total',survey_total);
        if (tab_index >= 0 || page >= 0) {
            if (tab_index == '' || tab_index == null) {
                tab_index = 0;
            }

            $(".search_table").hide().eq(tab_index).show();
            $(".feedback_ul").find("li a").removeClass("a_active");
            $(".feedback_ul li a").eq(tab_index).addClass("a_active");
            get_data(tab_index+1,page);
        }else {
            get_data(1,1);
        }
    });
    // 搜索 姓名，手机号，id
    document.onkeydown = function (event){
        var search=$('#search').val();
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(search!=''){
            if (e && e.keyCode == 13){ // enter 键
                //搜索用户
                var tab_index = parseInt(sessionStorage.getItem('manager_tab_index'));
             get_data(tab_index+1,1,search);
            }
        }
    };
</script>
</body>

</html>